<template>
    <div class="layerRtb layerRtb-threecolumn">
        <three-title :title="{name:'订单评价'}"></three-title>
          <div class="layerRtb-scroll thinScroll" v-scrollHeight="437" v-if="newIntegral.length>0">
            <div class="analyItem"  v-for="(item,index) in newIntegral" :key="index">
                <p class="analyItemTit tx-center">订单-{{index+1}}</p>
                <div class="analyItemCon">
                    <p class="col-md-5">时间：
                        <span class="cLightGray pr8">{{item.des_time}}</span>
                    </p>
                     <p class="col-md-3">操作人
                        <span class="cLightGray pr8">客服</span>
                    </p>
                    <p class="col-md-4">积分：
                        <span class="cLightGray pr8">{{item.score}}</span>
                    </p>
                       <p class="col-md-12">内容：
                        <span class="cLightGray pr8">{{item.describe}}</span>
                    </p>
                </div>
            </div>
        </div>
         <div class="layerRtb-scroll thinScroll" v-scrollHeight="437" v-else>
                <div class="analyItem">
                    <p class="analyItemTit tx-center">订单</p>
                    <div class="analyItemCon">
                        <p class="col-md-12">
                            <span>暂无内容！</span>
                        </p>
                    </div>
                </div>
        </div>
        <div class="layerRtb-footer">
            <div class="analyItem">
                <p class="analyItemTit tx-center">综合</p>
                <div class="analyItemCon">
                        <p class="col-md-2">
                            <span>次数</span>
                            <span>{{newIntegral.length}}</span>
                        </p>
                        <p class="col-md-3">
                            <span>奖励</span>
                            <span>{{dindanH}}</span>
                        </p>
                        <p class="col-md-2">
                            <span>积分</span>
                            <span>{{dindanC}}</span>
                        </p>
                        <p class="col-md-3">
                            <span>合计</span>
                            <span>{{dindanC+dindanH}}</span>
                        </p>
                        <p class="col-md-2">
                            <span  @click="clickFourShow(0)">历史</span>
                        </p>
                </div>
            </div>
        </div>
          <transition-group class="animated faster" enter-active-class="animated faster slideInRight" leave-active-class="animated faster slideOutRight">
        <!-- 问题 threeresultDetail -->
        <rx-history v-if="fourIndex === 0" :key="0" :basic="basic"></rx-history>
    </transition-group>
    </div>
</template>
<script>
import { mapGetters } from 'vuex'
import {complaintsIntegralHistory, getProblemIntegral, findNewIntegral} from '../../Resources/Api/index'
import rxHistory from './history/complaintsHistory'
export default {
    components: {
        rxHistory
    },
    data () {
        return {
            Complaint: [],
            fourIndex: undefined,
            tIntegral: 0,
            tIntegralObject: [],
            toushu: 0,
            newIntegral: {},
            dindanH: 0,
            dindanC: 0
        }
    },
    created () {
        this.getDNewIntegral()
    },
    methods: {
        GetDeposit () {
            let _this = this
            _this.Complaint = []
            complaintsIntegralHistory({
                uId: _this.leftInfo.uid,
                cuurentMonth: '2'
            }).then(results => {
                _this.Complaint = results.data.Body
                if (_this.Complaint == null) {
                    _this.Complaint = []
                }
            }).catch(error => {
                console.log(error)
            })
        },
        // 订单评价
        getDNewIntegral () {
            let _this = this
            _this.newIntegral = {}
            findNewIntegral({
                type: '2,3,4,5',
                uid: this.leftInfo.uid
            }).then(result => {
                this.newIntegral = result.data.Body
                this.dindanH = 0
                this.dindanC = 0
                this.newIntegral.forEach(element => {
                    if (element.subject === 1) {
                        this.dindanH += element.score
                        console.log(this.dindanH, '好')
                    } else {
                        this.dindanC += element.score
                        console.log(this.dindanC, '差')
                    }
                })
            }).catch(err => {
                console.log(err)
            })
        },
        clickFourShow (index) {
            this.fourIndex = index
        },
        ProblemIntegral () {
            let _this = this
            getProblemIntegral({
                pmId: this.leftInfo.uid
            }).then(result => {
                _this.tIntegralObject = result.data.Body.problemIntegralList
                _this.tIntegral = result.data.Body.problemIntegralList.map(list => list.integral).reduce((acc, cur) => (parseFloat(cur) + acc), 0)
            }).catch(err => {
                console.log(err)
            })
        }
    },
    computed: {
        ...mapGetters(['leftInfo']),
        compluedTask () {
            return this.Complaint.map(item => item.haPenalty).reduce((acc, cur) => (cur + acc), 0)
        }
    },
    watch: {
        leftInfo () {
            this.getDNewIntegral()
        }
    }
}

</script>
<style>
.dise[data-v-24cdde85] {
    color: #e46c00;
    background: #ffcaa4;
}
.dise[data-v-24cdde85], .diseR[data-v-24cdde85] {
    line-height: 22px;
    display: block;
    border-radius: 9px;
    padding: 0 5px;
    float: left;
    margin-top: 5px;
}
</style>
